package svc

import "monitor/shared"
import "monitor/rpc/status/internal/config"

//手动代码
import "monitor/rpc/status/model"
import "github.com/tal-tech/go-zero/core/stores/sqlx"
import "github.com/tal-tech/go-zero/core/stores/cache"
import "github.com/tal-tech/go-zero/core/syncx"

type ServiceContext struct {
	Config     config.Config
	Model      model.TbStatusModel // 手动代码
	ModelAlarm model.TbAlarmModel  // 手动代码
	Cache      cache.Cache
}

func NewServiceContext(c config.Config) *ServiceContext {
	//缓存
	ca := cache.New(c.Cache, syncx.NewSharedCalls(), cache.NewStat("cmdset"), shared.ErrNotFound)
	return &ServiceContext{
		Config:     c,
		Model:      model.NewTbStatusModel(sqlx.NewMysql(c.DataSource), c.Cache), // 手动代码
		ModelAlarm: model.NewTbAlarmModel(sqlx.NewMysql(c.DataSource), c.Cache),
		Cache:      ca,
	}
}
